//
//  XSJRecommendedCollectionCell.m
//  XSJ
//
//  Created by yuanyuan he on 2020/5/8.
//  Copyright © 2020 apple. All rights reserved.
//

#import "XSJRecommendedCollectionCell.h"
#import "UIImageView+WebCache.h"

@interface XSJRecommendedCollectionCell()

@property (nonatomic, strong) UIImageView* iconView;
@property (nonatomic, strong) UIButton* liveBroadcastButton;

@end

@implementation XSJRecommendedCollectionCell

- (instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self)
    {
        [self setup];
    }
    return self;
}

- (void)setup
{
    self.contentView.backgroundColor = ColorHex(0xffffff);
    
    [self.contentView addSubview:self.iconView];
    [self.contentView addSubview:self.liveBroadcastButton];
    
    [_iconView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(0);
        make.top.mas_equalTo(30);
        make.right.mas_equalTo(-0);
        make.width.height.mas_equalTo(60);
    }];
    
    [_liveBroadcastButton mas_makeConstraints:^(MASConstraintMaker *make) {
        make.bottom.equalTo(self->_iconView.mas_bottom);
        make.centerX.equalTo(self->_iconView);
        make.width.mas_equalTo(42);
        make.height.mas_equalTo(16);
    }];
    
}

//-(void)setModel:(HotHouseModel *)model
//{
//    _model = model;
//
//    //房间头像
//    if (!kStringIsEmpty(_model.picture))
//    {
//        [_iconView sd_setImageWithURL:[NSURL URLWithString:model.picture]];
//    }
//
//    if (_model.isFollow)
//    {
//        [_attentionButton setTitle:@"已关注" forState:UIControlStateNormal];
//    }
//    else
//    {
//       [_attentionButton setTitle:@"+关注" forState:UIControlStateNormal];
//    }
//
//}

- (void)liveBroadcastButtonDidClick
{
    
}

- (UIImageView *)iconView {
    if (_iconView == nil) {
        _iconView = [[UIImageView alloc] init];
        _iconView.image = [UIImage imageNamed:@"man1"];
        _iconView.clipsToBounds = YES;
        _iconView.layer.cornerRadius = 5.0f;
    }
    return _iconView;
}

- (UIButton *)liveBroadcastButton {
    if (_liveBroadcastButton == nil) {
        _liveBroadcastButton = [UIButton buttonWithType:UIButtonTypeCustom];
        [_liveBroadcastButton setTitle:@"正在直播" forState:UIControlStateNormal];
        [_liveBroadcastButton setTitleColor:ColorHex(0xFFFFFF) forState:UIControlStateNormal];
        _liveBroadcastButton.backgroundColor = ColorHex(0xCC88F0);
        _liveBroadcastButton.titleLabel.font = [UIFont systemFontOfSize:8];
        _liveBroadcastButton.layer.cornerRadius = 8;
        _liveBroadcastButton.clipsToBounds = YES;
        //不接受点击事件
        _liveBroadcastButton.userInteractionEnabled = NO;
        [_liveBroadcastButton addTarget:self action:@selector(liveBroadcastButtonDidClick) forControlEvents:UIControlEventTouchUpInside];
    }
    return _liveBroadcastButton;
}

@end
